/*企业信用评分-列表*/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:frametrim/route/Routes.dart';
import 'package:frametrim/utility/sq_color.dart';
import 'package:frametrim/views/background_view.dart';
import 'package:get/get.dart';

import '../../appviews/StatueAndPointMarkView.dart';
import '../../appviews/lineToTextView.dart';
import '../../appviews/refresh/CustomRefreshFooter.dart';
import '../../appviews/refresh/CustomRefreshHeader.dart';
import '../../views/appbar_search_toAppbar.dart';

class CompanyCreditPointPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => CompanyCreditPointState();
}

class CompanyCreditPointState extends State<CompanyCreditPointPage> {
  TextEditingController _controller = TextEditingController();

  EasyRefreshController _refreshController = EasyRefreshController();

  List<String> mData = ['良好', '优秀', '警示', '失信'];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: SQColor.color_background,
      body: AnnotatedRegion(
        value: SystemUiOverlayStyle.dark,
        child: Column(
          children: [
            AppbarSearchUseAppBarTitle(
              imgStr: 'image/imv_back.png',
              controller: _controller,
              callback: (str) {},
              backgroundColor: SQColor.color_background,
              isNeedJump: true,
              isShowSearchImg: false,
              isNeedCenter: false,
            ),
            Expanded(
                child: EasyRefresh(
                    controller: _refreshController,
                    header: CustomRefreshHeader(),
                    footer: CustomRefreshFooter(),
                    onRefresh: () async {
                      Future.delayed(Duration(milliseconds: 2000), () {
                        _refreshController.finishRefresh();
                      });
                    },
                    onLoad: () async {
                      Future.delayed(Duration(milliseconds: 2000), () {
                        _refreshController.finishLoad(success: true);
                      });
                    },
                    child: ListView.builder(
                      shrinkWrap: true,
                      itemBuilder: (context, index) {
                        // return Text('123123');
                        return buildItem(mData[index]);
                      },
                      itemCount: 4,
                    )))
          ],
        ),
      ),
    );
  }

  Widget buildItem(String name) {
    return GestureDetector(
      onTap: () {
        Get.toNamed(Routes.Company_Credit_Point_Details,arguments: name);
      },
      child: BackgroundView(
        widget: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Expanded(
                    child: LineToTextView(
                        text1: "郑州市第二建筑工程有限责任公司",
                        textSize: 16,
                        isBind: false,
                        paddingTop: 8,
                        textColor: SQColor.color_3D3D3D)),
                SizedBox(width: 20),
                buildMark(name),
              ],
            ),
            SizedBox(height: 16),
            Text('统一社会信用代码：91410100MA44Q8G70K',
                style: TextStyle(fontSize: 14, color: SQColor.color_60black)),
          ],
        ),
      ),
    );
  }

  /*右侧mark*/
  Widget buildMark(String name) {
    Widget mWidget = StatueAndPointMarkView(
      mState: '良好',
      mPoint: '118分',
      fullColor: Color(0xFFECF2FE),
      borderColor: Color(0xFF0052D9),
    );
    if (name == '优秀') {
      return StatueAndPointMarkView(
        mState: '优秀',
        mPoint: '118分',
        fullColor: Color(0xFFE8F8F2),
        borderColor: Color(0xFF00A870),
      );
    } else if (name == '警示') {
      return StatueAndPointMarkView(
        mState: '警示',
        mPoint: '118分',
        fullColor: Color(0xFFFEF3E6),
        borderColor: Color(0xFFED7B2F),
      );
    } else if (name == '失信') {
      return StatueAndPointMarkView(
        mState: '失信',
        mPoint: '118分',
        fullColor: Color(0xFFFDECEE),
        borderColor: Color(0xFFE34D59),
      );
    }
    return mWidget;
  }
}
